package huawei.js2025;

import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

/**
 * 跳房子I
 */
public class Question47 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String string = sc.nextLine();
        List<Integer> list = Arrays.stream(string.substring(1, string.length() - 1).split(",")).map(Integer::parseInt).collect(Collectors.toList());
        int target = sc.nextInt();


        int indexMin = Integer.MAX_VALUE;
        int index1 = 0;
        int index2 = 0;
        for (int i = 0; i < list.size() - 1; i++) {
            for (int j = i + 1; j < list.size(); j++) {
                if (list.get(i) + list.get(j) == target) {
                    if (indexMin > i + j) {
                       index1 = i;
                       index2 = j;
                       indexMin = i + j;
                    }
                }
            }
        }

        System.out.println("[" + list.get(index1) + "," + list.get(index2) + "]");
    }
}
